#pragma once

#include <AVUIEventableObject.h>

namespace AVUI {

class RoutedCommand;
class ExecutedRoutedEventArgs;
class CommandBinding : public EventableObject
{
    friend class CommandManager;
public:
    CommandBinding(RoutedCommand* pCommand, TDelegate<ExecutedRoutedEventArgs>* pExecuted) : m_pCommand(pCommand) 
    { 
        AddEventHandler(get_ExecutedEvent(), pExecuted);
    }
                                        
    DECLARE_ELEMENT(CommandBinding, Object);

    IMPLEMENT_EVENT(Executed, ExecutedRoutedEventArgs);
    IMPLEMENT_EVENT(PreviewExecuted, ExecutedRoutedEventArgs);

    RoutedCommand* get_Command() { return m_pCommand; }

private:

    void OnExecuted(Object* pSender, ExecutedRoutedEventArgs* pArgs);

    RoutedCommand* m_pCommand;
};

};
